from django.db import models
from lib.CommonModels import CommonModel


class Blog(models.Model):
    '''
    个人站点表：包含站点名称、站点标题、站点样式
    '''
    name = models.CharField(max_length=64, verbose_name='站点名称', help_text='存放用户地址栏位置的名称')
    title = models.CharField(max_length=64, verbose_name='站点标题')
    theme = models.FileField(upload_to='../static/theme', null=True, verbose_name='站点样式',
                             help_text='存放用户css/js文件路径')

    class Meta():
        db_table = 'blog_info'
        verbose_name_plural = '用户站点表'

    def __str__(self):
        return f"站点{self.name}"


class Advertisement(CommonModel):
    title = models.CharField(max_length=32, verbose_name='广告标题')
    content = models.TextField(verbose_name='广告描述')
    phone = models.BigIntegerField(verbose_name='联系电话')
    img = models.FileField(upload_to='advertisement/', default='advertisement/default.jpg',
                           verbose_name='广告图片')
    is_background = models.BooleanField(default=False, verbose_name='是否轮播图展示', help_text='给钱上轮播图')

    class Meta():
        db_table = 'advertisement'
        verbose_name_plural = '广告表'

    def __str__(self):
        return f"广告 {self.title}"
